# 1.准备数据(生成)
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
# from 线性回归模型的类封装 import LinearRegression

X,y = make_regression(n_samples=150, n_features=4)          # 自创数据集
print(X.shape)          # 打印形状
print(y.shape)          # 打印形状

# 2.准备模型
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.15)
lr = LinearRegression()

# 3.模型训练
lr.fit(X_train,y_train)

# 4.模型评估
s = mean_squared_error(y_test,lr.predict(X_test))
print(s)

# 5.模型预测

# lr.predict(X_new)

